/*
 * @Author: your name
 * @Date: 2020-11-11 13:41:12
 * @LastEditTime: 2021-11-18 02:39:53
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bfgj-intelligent-design-ui\src\mixins\add-or-update-module.js
 */
export default {
  data() {
    return {
      addOrUpdateVisible: false, // 新增/更新弹窗visible状态
      attentionVisible: false, // 对比弹窗的visible状态
      modelEditVisible: false, // 模型详情页面编辑弹窗的visible状态
      openFileVisible: false, // 模型详情页面直接打开文件弹窗visible状态
      importModelVisible: false, // 模型列表页面导入模型弹窗visible状态
      testFileUploadVisible: false, // 试验数据页面上传试验附件弹窗visible状态
      choosedTestIds: []
    }
  },
  methods: {
    // 公告通知页面使用的新增方法
    onHandlerClickAdd() {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.initAdd()
      })
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
        this.$refs.addOrUpdate.init()
      })
    },
    // 试验列表的对比弹窗  cj add 20200522
    attentionHandle() {
      this.choosedTestIds = []
      if (this.dataListSelections.length < 2) {
        this.attentionVisible = true
        this.$nextTick(() => {
          this.$refs.attentionBox.init()
        })
      } else {
        this.$nextTick(() => {
          for (let i = 0; i < this.dataListSelections.length; i++) {
            this.choosedTestIds.push(this.dataListSelections[i].id)
          }
          this.$router.push({ path: '/testdetailCompare', query: { id: this.choosedTestIds }})
        })
      }
    },
    // 模型列表页面：导入模型弹窗 cj add 20200811
    importModelHandle(id) {
      this.importModelVisible = true
      this.$nextTick(() => {
        // 传入被导入的项目id
        this.$refs.importModel.dataForm.projectId = id
        this.$refs.importModel.init()
      })
    },
    // 模型详情页面：编辑模型弹窗 cj add 20200810
    modelEditHandle(id) {
      this.modelEditVisible = true
      this.$nextTick(() => {
        this.$refs.ModelEdit.dataForm.id = id
        this.$refs.ModelEdit.init()
      })
    },
    // 模型详情页面：直接打开弹窗 cj add 20200810
    openFileHandle(id) {
      this.openFileVisible = true
      this.$nextTick(() => {
        this.$refs.fileDetail.dataForm.id = id
        this.$refs.fileDetail.init()
      })
    },
    // 试验数据页面：试验附件新增弹窗 cj add 20201022
    uploadFileHandle(topicId) {
      this.testFileUploadVisible = true
      this.$nextTick(() => {
        this.$refs.enclosureDialog.topicId = topicId
        this.$refs.enclosureDialog.init()
      })
    }
  }
}
